<?php
class SuMaSms {
	private $CorpID = "htxgcwcom106";
	private $Pwd = "htxgcwcom123456";
	private $url = "http://120.132.132.102/WS/LinkWS.asmx?wsdl";
	private $port = "";
	private $type = "1";
	private $subid = "";
	private static $single = null;
	function __construct($type = 1) {
		if (! class_exists ( "SoapClient" )) {
			die ( "请开启Soap扩展" );
			exit ();
		}
		if (self::$single == null) {
			self::$single = new SoapClient ( $this->url );
		}
	}
	function _BatchSend2($mobile, $content) {
            $params = array (
                 'CorpID' => $this->CorpID,
                 'Pwd' => $this->Pwd,
                 'Mobile' => $mobile,
                 'Content' => $content
            );
            $result = self::$single->BatchSend2( $params );
            return self::_getCodeStatus($result->BatchSend2Result);
	}
	function _GetReportSMS(){
		$params = array (
                    'CorpID' => $this->CorpID,
                    'Pwd' => $this->Pwd
		);
		$r = self::$single->GetReportSMS($params);
		$data =  array();
		$data =  $this->object2array($r);
		return $data['GetReportSMSResult'];
	}
	function object2array($object) {
		$array = array();
		if (is_object($object)) {
			foreach ($object as $key => $value) {
				if(is_object($value)){
					$array[$key] = $this->object2array($value);
				}else{
					$array[$key] = $value;
				}
			}
		}else {
			$array = $object;
		}
		return $array;
	}
	static function _getCodeStatus($status) {
		$arrCode = self::reponseCode();
                if ($status>0) $status=0;
		return $arrCode [$status];
	}
	private static function reponseCode() {
		return array (
				"0" => "操作成功",
				"-1" => "账号无效",
				"-2" => "参数：无效",
				"-3" => "帐号或密码错误",
				"-5" => "余额不足，请先充值",
				"-6" => "定时发送时间不是有效的时间格式",
				"-8" => "发送内容需在1到300字之间",
				"-9" => "发送号码为空",
				"-10" => "定时时间不能小于系统当前时间",
				"-100" => "限制IP访问",
                                "-101" => "调用接口速度太快"
		);
	}
}
?>